home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / cmcalc.zip / CMCALC.DOC < prev    next >
Text File  |  1991-10-22  |  22KB  |  505 lines

  1.  
  2.  
  3.                       ***  COMPUTER MATH CALCULATOR  ***
  4.                       ***      FOR THE HP 95LX       ***
  5.  
  6.  
  7.                       Copyright (c) 1991 by Eugene Dorr
  8.                              All rights reserved.
  9.  
  10.  
  11. CMCALC is distributed in an archive called CMCALC.ZIP.  When "unzipped", you
  12. should have three files:
  13.  
  14.            CMCALC.DOC -- this documentation file
  15.            CMCALC.EXM -- executable file
  16.            APNAME.LST -- system manager application list
  17.  
  18. CMCALC is a system-manager compliant application which provides a rich set
  19. of computer-science-oriented integer manipulations.  It features variable
  20. word size (from 1 to 32 bits), selectable complement modes (unsigned, 1's
  21. complement, and 2's complement), four number bases (binary, octal, decimal
  22. and hexadecimal), and visible carry and overflow indicators.  Only RPN
  23. entry is supported.
  24.  
  25. Because CMCALC is "system-manager compliant" it can be started and used along
  26. with all other system-manager compliant applications, including the built-in
  27. applications.  You can switch between these applications without quitting any
  28. of them, and when you return to an application, you are returned right where
  29. you were when you left.  Of course, this also means that CMCALC will operate
  30. ONLY on HP 95LX computers.
  31.  
  32.  
  33.  
  34. Installing CMCALC
  35. -----------------
  36.  
  37. Basic installation of CMCALC is easy:
  38.  
  39.   (1) Copy CMCALC.EXM to the root directory on the HP 95's drive C:
  40.  
  41.   (2) Copy APNAME.LST to the _DAT subdirectory on the HP 95's drive C:
  42.  
  43.   (3) Quit all active applications and reboot the HP 95 by pressing
  44.       CTRL + ALT + DEL.
  45.  
  46.   (4) Start CMCALC by holding down the ALT key and pressing the blue
  47.       HP CALC key.
  48.  
  49. If you already have an APNAME.LST file on your drive C:, then just use the
  50. built-in MEMO application to add the following line to your existing
  51. APNAME.LST file:
  52.  
  53.   C:CMCALC.EXM,C300,CompMathCalc
  54.  
  55. If you want to install CMCALC on a RAM card, then the APNAME.LST file must
  56. be copied to the root directory on drive A:.
  57.  
  58.  
  59.  
  60. Using CMCALC
  61. ------------
  62.  
  63. To start CMCALC once it has been installed, hold down the ALT key and press
  64. the blue HP CALC key.  To quit CMCALC, press MENU, Q.  CMCALC uses the HP 95
  65. calculator paradigm, so if you are familiar with using the built-in HP 95
  66. calculator, operation of CMCALC should be straight-forward.
  67.  
  68. CMCALC uses the RPN mode of data entry.  This documentation assumes that you
  69. are familiar with RPN; if you are not, it is discussed in Appendix D of the
  70. HP 95LX User's Guide.  The CMCALC calculator operates on integers.  If you
  71. need to operate on floating-point numbers, you can use the HP 95 built-in
  72. calculator.
  73.  
  74.  
  75.  
  76. Controlling How CMCALC Works
  77. ----------------------------
  78.  
  79. You can control how CMCALC operates in several ways:  you can specify how many
  80. bits will be used to store numbers (the WORD SIZE -- from 1 to 32 bits); you
  81. can specify what complement mode is to be used (the complement mode affects the
  82. results of arithmetic functions, and the display of numbers in decimal mode),
  83. you can choose the number base you wish numbers to be displayed in (base 2 --
  84. binary, base 8 -- octal, base 10 -- decimal, or base 16 -- hexadecimal); and
  85. whether you want leading zeros to be displayed.  All of these features are
  86. controlled using MENUs.
  87.  
  88. For each of the following procedures, the operation may be aborted before it
  89. has been completed by pressing ESC once (if at the first level menu) or
  90. twice.
  91.  
  92. WORDSIZE
  93. To set the wordsize, press MENU W(ordsize).  Type in the number of bits per
  94. word (in decimal) and press ENTER.  You may specify any wordsize between 1
  95. and 32, inclusive.  Except in unsigned mode, the high bit of a word indicates
  96. the sign of a number.
  97.  
  98. COMPLEMENT MODE
  99. To set the complement mode, press MENU C(omplement).  A secondary menu appears,
  100. which gives you the option of Unsigned mode, 1's complement mode, or 2's
  101. complement mode.  Press U to select unsigned mode, 1 to select 1's complement
  102. mode, or 2 to select 2's complement mode.  In unsigned mode all numbers are
  103. considered to be positive.
  104.  
  105. BASE
  106. To set the base used for displaying numbers, press MENU B(ase).  A secondary
  107. menu appears, which gives you the option of Binary, Octal, Decimal, or
  108. Hexadecimal.  When numbers are displayed in decimal mode, a minus sign (-)
  109. is used to indicate negative numbers, and leading zeros are never displayed,
  110. even if that option is selected.
  111.  
  112. LEADING ZEROS
  113. You may prefer to see numbers displayed with leading zeros.  This option can
  114. be toggled on and off by pressing MENU O(ptions) L(eadingZeros).  In decimal
  115. mode, leading zeros are never displayed.
  116.  
  117. STATUS
  118. To see the current number base, word size, and complement mode, press MENU
  119. S(tatus).  A window will appear which show the current settings.  Press ESC
  120. to remove the window.
  121.  
  122. ERASE
  123. MENU E(rase) causes a secondary menu to be displayed, which gives you the
  124. option of zeroing the calcline (the X register), the storage registers
  125. (registers 0..9 and A..F), the stack (registers X, Y, Z and T), or the
  126. flags (Carry and Overflow).
  127.  
  128.  
  129.  
  130. Functions
  131. ---------
  132.  
  133. In the following descriptions, upper case X, Y, Z and T refer to the stack
  134. registers, lower case x, y, z and t refer to the values contained in the
  135. corresponding stack registers.  No stack movement occurs unless explicitly
  136. stated.  The Carry and Overflow flags are unaffected unless stated otherwise.
  137.  
  138. The Carry flag is usually used to indicate the value of a bit in the result
  139. which could not be accomodated in the current size of the register, for
  140. example, a carry during addition, a borrow during subtraction, or a bit
  141. shifted out of a register during a shift function.  The Overflow flag is
  142. used to indicate that the result could not be expressed within the current
  143. register size and complement mode.  For example, if the wordsize is 8 and the
  144. complement mode is 2's complement, then the largest positive number which can
  145. be expressed is 127, and the largest negative number which can be expressed
  146. is -128.  If the CHS (change sign) function is applied to -128, then the
  147. Overflow flag will be set, since +128 cannot be expressed in 8 bits.
  148.  
  149. Some functions (the ones which refer to bit positions) use the absolute
  150. (positive) value of x.  This is indicated by the notation |x|.
  151.  
  152. As with the HP 95 built-in calculator, many functions are assigned to F-keys,
  153. which are labelled on the last two lines of the display.  Four groups of
  154. functions are available, and the different groups are accessed by pressing
  155. F10 (labelled 'More').  In the following descriptions, functions which are
  156. assigned to Fkeys carry the notation '(Fkey)'.
  157.  
  158.  
  159. ARITHMETIC FUNCTIONS
  160.  
  161. +        Add -- (+)
  162.          x is added to y, result returned in X.  The stack drops.  Carry and
  163.          Overflow are set as appropriate for the complement mode.
  164.  
  165. -        Subtract -- (-)
  166.          x is subtracted from y, result returned in X.  The stack drops.  Carry
  167.          and Overflow are set as appropriate for the complement mode.
  168.  
  169. *        Multiply -- (*)
  170.          x is multiplied by y, result returned to X, the stack drops.  Overflow
  171.          is sometimes set if the result cannot be represented in the current
  172.          wordsize and complement mode.  The overflow flag is not a reliable
  173.          indication of whether an overflow occured with this function.
  174.  
  175. /        Divide -- (/)
  176.          The quotient of y divided by x, result returned in X.  The stack
  177.          drops.  The Carry flag is set if there is a remainder, otherwise it is
  178.          cleared.  Overflow is set only in 2's complement mode when the largest
  179.          possible negative number is divided by -1.  In all other cases it is
  180.          cleared.  The function is inhibited and an error message is displayed
  181.          if x is 0 or -0.
  182.  
  183. ABS      Absolute value -- (Fkey)
  184.          If x is negative (this can only be true if the complement mode is not
  185.          unsigned) then it is made positive, if possible, the result is
  186.          returned to X, and Overflow is reset.  If it is not possible to make x
  187.          positive (i.e. the complement mode is 2's complement, and x is the
  188.          largest possible negative number), then X remains unchanged and the
  189.          Overflow flag is set.
  190.  
  191. RMD      Remainder -- (Fkey)
  192.          y is divided by x, the quotient is discarded, and the remainder is
  193.          returned in X.  The stack drops.  The function is inhibited and an
  194.          error message is displayed if x is 0 or -0.
  195.  
  196. CHS      Change Sign -- (assigned to the 'L' key)
  197.          Complements x, result returned in X.  Carry and Overflow are set as
  198.          appropriate for the complement mode.  The function is inhibited and an
  199.          error message is displayed in unsigned mode.
  200.          
  201.  
  202. BOOLEAN LOGIC FUNCTIONS
  203.  
  204. AND      Bitwise AND -- (Fkey)
  205.          Bitwise logical AND of x and y, result returned in X.  The stack drops.
  206.  
  207. OR       Bitwise OR -- (Fkey)
  208.          Bitwise logical OR of x and y, result returned in X.  The stack drops.
  209.  
  210. XOR      Bitwise Exclusive OR -- (Fkey)
  211.          Bitwise logical exclusive OR of x and y, result returned in X.  The
  212.          stack drops.
  213.  
  214. NOT      Bitwise NOT -- (Fkey)
  215.          Bitwise logical NOT of x, result returned in X.
  216.  
  217.  
  218. BIT-MANIPULATION FUNCTIONS
  219.  
  220. MASKL    Mask left -- (Fkey)
  221.          A bit mask of the size specified by |x| is created and placed in the
  222.          leftmost positions of X, replacing x.
  223.  
  224. MASKR    Mask right -- (Fkey)
  225.          A bit mask of the size specified by |x| is created and placed in the
  226.          rightmost positions of X, replacing x.
  227.  
  228. SB       Set bit -- (Fkey)
  229.          The bit specified by |x| (x=0 specifies the rightmost bit) is set in y,
  230.          the result is returned in X.  The stack drops.
  231.  
  232. CB       Clear bit -- (Fkey)
  233.          The bit specified by |x| (x=0 specifies the rightmost bit) is cleared
  234.          in y, the result is returned in X.  The stack drops.
  235.  
  236. INV      Invert bit order -- (Fkey)
  237.          The order of the bits in x is reversed, the result is returned in X.
  238.  
  239. #BIT     Bit count -- (Fkey)
  240.          The number of 1-bits in x is returned in X.
  241.  
  242.  
  243. SHIFT AND ROTATE FUNCTIONS
  244.  
  245. SL       Shift left -- (Fkey)
  246.          x is shifted to the left by one position, a zero bit is introduced
  247.          into the rightmost bit position, and the result is returned in X.
  248.          The Carry flag is set to the value of the leftmost bit of x.
  249.  
  250.                        +---+     +----------------+
  251.                        |   | <-- |     <-----     | <-- 0
  252.                        +---+     +----------------+
  253.                        Carry
  254.  
  255. SR       Shift right -- (Fkey)
  256.          x is shifted to the right by one position, a zero bit is introduced
  257.          into the leftmost bit position, and the result is returned in X.
  258.          The Carry flag is set to the value of the rightmost bit of x.
  259.  
  260.                              +----------------+     +---+
  261.                        0 --> |     ----->     | --> |   |
  262.                              +----------------+     +---+
  263.                                                     Carry
  264.  
  265. SLn      Shift left multiple -- (Fkey)
  266.          y is shifted to the left by the number of positions specified by |x|,
  267.          zero bits are introduced into the vacated rightmost bit positions,
  268.          the result is returned in X.  The stack drops.  The Carry flag is set
  269.          to the value of the last bit to be shifted from the leftmost position
  270.          of y.
  271.  
  272. SRn      Shift right multiple -- (Fkey)
  273.          y is shifted to the right by the number of positions specified by |x|,
  274.          zero bits are introduced into the vacated leftmost bit positions,
  275.          the result is returned in X.  The stack drops.  The Carry flag is
  276.          set to the value of the last bit to be shifted from the rightmost
  277.          position of y.
  278.  
  279. ASR      Arithmetic shift right -- (Fkey)
  280.          x is shifted to the right by one position, the leftmost bit retains
  281.          its original value, the result is returned in X.  The Carry flag is
  282.          set to the value of the leftmost bit of x.
  283.  
  284.                         +------+
  285.                         |      |
  286.                         |    +----------------+     +---+
  287.                         +--> |     ----->     | --> |   |
  288.                              +----------------+     +---+
  289.                                                     Carry
  290.  
  291. LJ       Left justify -- (Fkey)
  292.          If x<0, then x is shifted left until the leftmost bit contains a one
  293.          bit.  The result is returned to Y.  The number of shifts performed is
  294.          returned in X.  The stack is lifted.  If x=0, the stack is lifted and
  295.          X and Y are set to 0.
  296.  
  297. RL       Rotate left -- (Fkey)
  298.          x is shifted left by one position, the value of the leftmost bit is
  299.          returned in the rightmost bit position, and also in the Carry flag.
  300.          The result is returned in X.
  301.  
  302.                               +--------------------------+
  303.                     +---+     |    +----------------+    |
  304.                     |   | <---+--- |     <-----     | <--+
  305.                     +---+          +----------------+
  306.                     Carry
  307.  
  308. RR       Rotate right -- (Fkey)
  309.          x is shifted right by one position, the value of the rightmost bit is
  310.          returned in the leftmost bit position, and also in the Carry flag.
  311.          The result is returned in X.
  312.  
  313.                     +--------------------------+
  314.                     |    +----------------+    |     +---+
  315.                     +--> |     ----->     | ---+---> |   |
  316.                          +----------------+          +---+
  317.                                                      Carry
  318.  
  319. RLn      Rotate left multiple -- (Fkey)
  320.          y is shifted left by |x| positions, and as each bit is shifted out of
  321.          the leftmost bit position, it is introduced into the rightmost bit
  322.          position, and into the Carry flag.  The result is returned in X.  The
  323.          stack drops.
  324.  
  325. RRn      Rotate right multiple -- (Fkey)
  326.          y is shifted right by |x| positions, and as each bit is shifted out of
  327.          the rightmost bit position, it is introduced into the leftmost bit
  328.          position, and into the Carry flag.  The result is returned in X.  The
  329.          stack drops.
  330.  
  331. RLC      Rotate left through carry -- (Fkey)
  332.          x is shifted left one position, the value of the Carry flag is
  333.          introduced into the vacated rightmost bit position, and the Carry
  334.          flag is set to the value of the bit shifted out of the leftmost
  335.          position.
  336.  
  337.                     +------------------------------------+
  338.                     |    +---+     +----------------+    |
  339.                     +--- |   | <-- |     <-----     | <--+
  340.                          +---+     +----------------+
  341.                          Carry
  342.  
  343. RRC      Rotate right through carry -- (Fkey)
  344.          x is shifted right one position, the value of the Carry flag is
  345.          introduced into the vacated leftmost bit position, and the Carry flag
  346.          is set to the value of the bit shifted out of the rightmost position.
  347.  
  348.                     +------------------------------------+
  349.                     |    +---+     +----------------+    |
  350.                     +--> |   | --> |     ----->     | ---+
  351.                          +---+     +----------------+
  352.                          Carry
  353.  
  354. RLCn     Rotate Left through Carry multiple -- (Fkey)
  355.          y is shifted left by |x| positions, and at each shift, the rightmost
  356.          bit position receives the value of the Carry bit, and the Carry bit
  357.          receives the value of the bit shifted out of the leftmost position.
  358.          The result is placed in X.  The stack drops.
  359.  
  360. RRCn     Rotate Right through Carry multiple -- (Fkey)
  361.          y is shifted right by |x| positions, and at each shift, the leftmost
  362.          bit position receives the value of the Carry bit, and the Carry bit
  363.          receives the value of the bit shifted out of the rightmost position.
  364.          The result is placed in X.  The stack drops.
  365.  
  366.  
  367. STACK CONTROL OPERATIONS
  368.  
  369. Rv       Roll Down -- (assigned to the 'v' key)
  370.          The contents of each stack register is shifted into the next lower
  371.          register, and x is shifted into T.
  372.  
  373. R^       Roll Up -- (assigned to the 'V' key)
  374.          The contents of each stack register is shifted into the next higher
  375.          register, and t is shifted into X.
  376.  
  377. x<>y     Exchange X and Y -- (assigned to the 'X' key)
  378.          The contents of the X and Y registers are exchanged.
  379.  
  380.  
  381. NUMBER STORAGE AND RETRIEVAL
  382.  
  383. STO      Store -- (assigned to the 'N' key)
  384.          The calculator waits for a register specifier - a digit key (0..9)
  385.          or A..F; when a register has been specified, x is stored into that
  386.          register.  The value may later be recalled to X by pressing RCL
  387.          and the same register specifier.  x remains in X.  The STO operation
  388.          may be cancelled before specifying a register, by pressing ESC.
  389.  
  390. RCL      Recall -- (assigned to the 'M' key)
  391.          As with STO, RCL must be followed by a register specifier.  The
  392.          stack is lifted and the value last stored into the specified register
  393.          is placed into X.  The value remains in the specified register.  The
  394.          RCL operation may be cancelled before specifying a register by
  395.          pressing ESC.
  396.  
  397. RCL L    Last X -- (Press the 'M' (RCL) key, followed by 'L')
  398.          Returns to X the value which was in X prior to the last function.
  399.  
  400.  
  401. MISCELLANEOUS
  402.  
  403. SHOW     Show X in all bases -- (Fkey)
  404.          The value in X is displayed simultaneously in binary, octal, decimal
  405.          and hexdecimal.  The complement and leading-zeros settings are
  406.          observed for each base displayed.  This display remains until a key
  407.          is pressed.  If ESC is pressed, then the SHOW display is erased, and
  408.          no action is taken.  If any other key is pressed, the SHOW display
  409.          is erased, and the action of that key is processed.  LastX is not set.
  410.  
  411. RCL V    Display version -- (Press the 'M' key (RCL), followed by 'V')
  412.          A window is displayed, which shows the version of CMCALC.
  413.  
  414.  
  415. NUMBER ENTRY
  416.  
  417. 0..9     Digits -- Used to enter numbers.  The letters A, B, C, D, E and F
  418. A..F     are used for digit entry in hexadecimal mode.
  419.  
  420. ENTER    Enter -- (ENTER)
  421.          Copies x into Y, and disables stack lift.  If entry mode is active,
  422.          it is terminated.
  423.  
  424. <--      Backspace -- (assigned to the backarrow key)
  425.          When entry mode is active (the cursor is displayed on the entry
  426.          line) the last digit entered is deleted.  If no digits remain,
  427.          entry mode is terminated.  When entry mode is not active, the X
  428.          register is set to zero, and stack lift is disabled.
  429.  
  430.  
  431.  
  432. Error Messages
  433. --------------
  434.  
  435. Divide by zero
  436.     A divide (/) or RMD function was attempted when the value in X was
  437.     0 or (in 1's complement mode) -0.  Division by 0 is undefined.
  438.  
  439. Exceeds current wordsize
  440.     A mask (MASKL or MASKR), bit-addressing (SB or CB), shift multiple
  441.     (SLn or SRn), or rotate multiple (RLn or RRn) function was attempted
  442.     and |x| was greater than the currently selected word size; or a rotate
  443.     through carry multiple (RLCn or RRCn) function was attempted and |x|
  444.     was greater than the currently selected word size + 1.  You can display
  445.     the currently selected word size by pressing MENU S.  You can change
  446.     the currently selected wordsize by pressing MENU W, entering the
  447.     desired wordsize (in decimal), and pressing ENTER.
  448.  
  449. Current mode is unsigned
  450.     You attempted to change the sign (using CHS) of a number, but the
  451.     currently selected complement mode is unsigned.  A negative number
  452.     cannot be expressed in unsigned mode.  You can display the currently
  453.     selected complement mode by pressing MENU S.  You can change the
  454.     currently selected complement mode by pressing MENU C, and then
  455.     pressing the first character of the desired complement mode.
  456.  
  457.  
  458.  
  459. The HP 95 Calculator Paradigm
  460. -----------------------------
  461.  
  462. I have tried to make CMCALC adhere to the HP 95 calculator paradigm, but
  463. there are some exceptions:
  464.  
  465. * Algebraic entry mode is not supported
  466. * STO @ and RCL @ are not supported
  467. * Shift-V performs roll-up
  468. * Square root and inverse are omitted
  469.  
  470. Since the "B" and "C" keys are used for entering hexadecimal numbers, they are
  471. unavailable for the standard LASTx and x<>y functions.  Therefore...
  472.  
  473. * LASTx is obtained by RCL L
  474. * x<>y is assigned to the X key
  475.  
  476.  
  477.  
  478. CMCALC Compared to the HP-16C
  479. -----------------------------
  480.  
  481. For those familiar with the HP-16C, CMCALC does not provide programmability,
  482. and omits functions directy related to programmability (there is no indirect
  483. register, no x?y or x?0 comparisons, no flag manipulaton functions, and no
  484. bit test (B?) function).  CMCALC also omits floating-point mode, and the
  485. square root function, since these are available in the built-in HP 95
  486. calculator.  The three DBL functions have been omitted.  Word size is
  487. limited to a maximum of 32 bits.  Whereas the HP-16C had a variable number
  488. of registers, CMCALC has a fixed set of 16 registers: 0..9 and A..F.
  489.  
  490.  
  491.  
  492. Problems, Bugs, Comments
  493. ------------------------
  494.  
  495. If you have problems with CMCALC, or have found a bug, or if you wish
  496. to contact me with suggestions for change or improvement (or just a
  497. friendly "hello"), you can contact me on CompuServe (75156.3132).
  498.  
  499. CMCALC may be freely copied and distributed ONLY in unmodified form, and
  500. you may not charge any fee for it.  I neither make nor express any warranty
  501. that CMCALC operates correctly (though I believe it to do so), or that it
  502. is suitable for your purposes (though I hope it is).
  503.  
  504. Gene Dorr
  505.